/*
 * @(#)QueryCriteria.java  
 *       
 * 系统名称＄1�7    OpenSeats信息系统
 * 版本号：      1.0
 *  
 * Copyright (c)  TravelSky.com
 * All rights reserved.
 * 
 * 作�1�7�1�7 	  yurb
 * 创建日期:    2008-10-5
 * 
 * 功能描述＄1�7
 * 公用方法描述＄1�7
 * 
 * 修改人：
 * 修改日期＄1�7
 * 修改原因＄1�7
 * 
 */
package com.bjypc.youth.common;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 
 * 翻页查询的封装类
 * 
 * @author yurb
 * @since 2008-10-5 下午02:39:23
 */
@SuppressWarnings("unchecked")
public class QueryCriteria implements java.io.Serializable
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 2733817626212324840L;

	/**
	 * Result sort direction is ascending
	 */

	public static final String SORT_DIRECTION_ASC = "ASC";

	/**
	 * Result sort direction is descending
	 */
	public static final String SORT_DIRECTION_DESC = "DESC";

	/**
	 * max query result line number.
	 */
	private int pageSize = Constants.PAGE_SIZE;

	private int currentIndex = 0;

	private String field = "";

	private String direction = "ASC";

	/**
	 * Query condition by specific business object.
	 */
	private Map queryCondition = new HashMap();

	/**
	 * sort condition, every object in list just like the [Property1 ASC]
	 * [Property2 ASC]
	 */
	private List sortCondition = new ArrayList();

	/**
	 * @return Returns the queryCondition.
	 */
	public Map getQueryCondition()
	{
		return queryCondition;
	}

	/**
	 * @param queryCondition
	 *            The queryCondition to set.
	 */
	public void setQueryCondition(Map queryCondition)
	{
		this.queryCondition = queryCondition;
	}

	public void addQueryCondition(Object key, Object value)
	{
		this.queryCondition.put(key, value);
	}

	public List getSortCondition()
	{
		return sortCondition;
	}

	public void setSortCondition(List sortCondition)
	{
		this.sortCondition = sortCondition;
	}

	public int getPageSize()
	{
		return pageSize;
	}

	public void setPageSize(int pageSize)
	{
		this.pageSize = pageSize;
	}

	public int getCurrentIndex()
	{
		return currentIndex;
	}

	public void setCurrentIndex(int currentIndex)
	{
		this.currentIndex = currentIndex;
	}

	public String getDirection()
	{
		return direction;
	}

	public void setDirection(String direction)
	{
		this.direction = direction;
	}

	public String getField()
	{
		return field;
	}

	public void setField(String field)
	{
		this.field = field;
	}

	public QueryCriteria copy()
	{
		QueryCriteria criteria = new QueryCriteria();
		criteria.setCurrentIndex(this.getCurrentIndex());
		criteria.setField(field);
		criteria.setPageSize(pageSize);
		criteria.setDirection(this.getDirection());
		criteria.getSortCondition().addAll(this.getSortCondition());
		criteria.getQueryCondition().putAll(this.getQueryCondition());
		return criteria;
	}

	public void reset()
	{
		currentIndex = 0;
		field = "";
		queryCondition.clear();

	}

}
